#include <bits/stdc++.h>
using namespace std;
bool isNum(char ch){
    if (ch >= '0' && ch <= '9') return true;
    return false;
}
bool isCharacter(char ch){
    if (ch >= 'a' && ch <= 'z') return true;
    return false;
}
void extract(string s,bool isUppercase,bool isReverse,bool isPassword,int cnt){
    char ch1=s[0];
    char ch2=s[2];
    if (ch2-ch1==1){
        cout<<ch1;
        return;
    }
    else if (ch1 >= ch2){
        cout<<s.substr(0,2);
    }
    else {
        cout<<ch1;
        string ans="";
        if (isReverse) {
            for (char i=ch2-1;i >= ch1+1;i--){
                for (int j=0;j<cnt;j++) {
                    if (isUppercase) ans.append(1,char(i-32));
                    else ans.append(1,i);
                }
            }
        }
        else {
            for (char i=ch1+1;i<=ch2-1;i++){
                for (int j=0;j<cnt;j++) {
                    if (isUppercase) ans.append(1,char(i-32));
                    else ans.append(1,char(i));
                }
            }
        }
        if (isPassword){
            for (int i=0;i<ans.length();i++) {
                cout<<"*";
            }
        }
        else {
            cout<<ans;
        }
    }
}
int main(){
    int p1,p2,p3;
    bool isReverse=0,isUppercase=0,isPassword=0;
    cin>>p1>>p2>>p3;
    string str;
    cin>>str;
    if (p3==1) isReverse=0;
    else isReverse=1;
    if (p1==1) isUppercase=0;
    else if (p1==2) isUppercase=1;
    else isPassword=1;
    while (str!=""){

        if (str[1]=='-' && 
        ((isCharacter(str[0]) && isCharacter(str[2]))
        ||(isNum(str[0]) && isNum(str[2])))){
            extract(str.substr(0,3),isUppercase,isReverse,isPassword,p2);
            str=str.substr(2);
        }
        else {
            cout<<str[0];
            str=str.substr(1);
        }
    }
    return 0;
}